<?php


namespace app\logic\model;


use think\Model;

class AuctionRecordModel extends Model
{
    protected $name='auction_record';

    /**
     * 获取金额最高的竞价信息
     * @param int $auction_opus_id 拍卖的id
     */
    function getHighest($auction_opus_id){
        return $this->where('auction_opus_id',$auction_opus_id)
            ->order('money desc')
            ->find();
    }
    /**
     * 获取金额最高的竞价金额
     * @param int $auction_opus_id 拍卖的id
     */
    function getHighestMoney($auction_opus_id){
        return $this->where('auction_opus_id',$auction_opus_id)
            ->order('money desc')
            ->value('money',0);
    }
    /**
     * 获取金额最高的竞价金额
     * @param int $auction_opus_id 拍卖的id
     * @param float $money 竞价金额
     */
    function insertAuctionRecord($auction_opus_id,$money){
        global $user;
        $data=array(
            'user_id'=>$user['id'],
            'auction_opus_id'=>$auction_opus_id,
            'money'=>$money,
        );
        return $this->save($data);
    }
}